1 /* global extDependencyMap */
7 var value
= $( this ).val()
8 .replace( /[\[\]{}|#<>%+? ]/g, '_' ) // eslint-disable-line no-useless-escape
9 .replace( /&/, '&' )
10 .replace( /__+/g, '_' )
12 .replace( /_+$/, '' );
13 value
= value
.charAt( 0 ).toUpperCase() + value
.slice( 1 );
14 $label
.text( labelText
.replace( '$1', value
) );
17 // Set up the help system
18 $( '.config-help-field-data' ).hide()
19 .closest( '.config-help-field-container' ).find( '.config-help-field-hint' )
21 .on( 'click', function () {
22 // FIXME: Use CSS transition
23 // eslint-disable-next-line jquery/no-slide
24 $( this ).closest( '.config-help-field-container' ).find( '.config-help-field-data' )
25 .slideToggle( 'fast' );
28 // Show/hide code for DB-specific options
29 // FIXME: Do we want slow, fast, or even non-animated (instantaneous) showing/hiding here?
30 $( '.dbRadio' ).each( function () {
31 $( document
.getElementById( $( this ).attr( 'rel' ) ) ).hide();
33 $( document
.getElementById( $( '.dbRadio:checked' ).attr( 'rel' ) ) ).show();
34 $( '.dbRadio' ).on( 'click', function () {
35 var $checked
= $( '.dbRadio:checked' ),
36 $wrapper
= $( document
.getElementById( $checked
.attr( 'rel' ) ) );
37 if ( $wrapper
.is( ':hidden' ) ) {
38 // FIXME: Use CSS transition
39 // eslint-disable-next-line jquery/no-animate-toggle
40 $( '.dbWrapper' ).hide( 'slow' );
41 // eslint-disable-next-line jquery/no-animate-toggle
42 $wrapper
.show( 'slow' );
46 // Scroll to the bottom of upgrade log
47 $( '#config-live-log' ).children( 'textarea' ).each( function () {
48 this.scrollTop
= this.scrollHeight
;
51 // Show/hide Creative Commons thingy
52 $( '.licenseRadio' ).on( 'click', function () {
53 var $wrapper
= $( '#config-cc-wrapper' );
54 if ( $( '#config__LicenseCode_cc-choose' ).is( ':checked' ) ) {
55 // FIXME: Use CSS transition
56 // eslint-disable-next-line jquery/no-animate-toggle
57 $wrapper
.show( 'slow' );
59 // eslint-disable-next-line jquery/no-animate-toggle
60 $wrapper
.hide( 'slow' );
64 // Show/hide random stuff (email, upload)
65 $( '.showHideRadio' ).on( 'click', function () {
66 var $wrapper
= $( '#' + $( this ).attr( 'rel' ) );
67 if ( $( this ).is( ':checked' ) ) {
68 // FIXME: Use CSS transition
69 // eslint-disable-next-line jquery/no-animate-toggle
70 $wrapper
.show( 'slow' );
72 // eslint-disable-next-line jquery/no-animate-toggle
73 $wrapper
.hide( 'slow' );
76 $( '.hideShowRadio' ).on( 'click', function () {
77 var $wrapper
= $( '#' + $( this ).attr( 'rel' ) );
78 if ( $( this ).is( ':checked' ) ) {
79 // FIXME: Use CSS transition
80 // eslint-disable-next-line jquery/no-animate-toggle
81 $wrapper
.hide( 'slow' );
83 // eslint-disable-next-line jquery/no-animate-toggle
84 $wrapper
.show( 'slow' );
88 // Hide "other" textboxes by default
89 // Should not be done in CSS for javascript disabled compatibility
90 if ( !$( '#config__NamespaceType_other' ).is( ':checked' ) ) {
91 $( '.enabledByOther' ).closest( '.config-block' ).hide();
94 // Enable/disable "other" textboxes
95 $( '.enableForOther' ).on( 'click', function () {
96 var $textbox
= $( document
.getElementById( $( this ).attr( 'rel' ) ) );
97 // FIXME: Ugh, this is ugly
98 if ( $( this ).val() === 'other' ) {
99 // FIXME: Use CSS transition
100 // eslint-disable-next-line jquery/no-slide
101 $textbox
.prop( 'readonly', false ).closest( '.config-block' ).slideDown( 'fast' );
103 // eslint-disable-next-line jquery/no-slide
104 $textbox
.prop( 'readonly', true ).closest( '.config-block' ).slideUp( 'fast' );
108 // Synchronize radio button label for sitename with textbox
109 $label
= $( 'label[for="config__NamespaceType_site-name"]' );
110 labelText
= $label
.text();
111 $label
.text( labelText
.replace( '$1', '' ) );
112 $( '#config_wgSitename' ).on( 'keyup change', syncText
).each( syncText
);
114 // Show/Hide memcached servers when needed
115 $( 'input[name$="config__MainCacheType"]' ).on( 'change', function () {
116 var $memc
= $( '#config-memcachewrapper' );
117 if ( $( 'input[name$="config__MainCacheType"]:checked' ).val() === 'memcached' ) {
118 // FIXME: Use CSS transition
119 // eslint-disable-next-line jquery/no-animate-toggle
120 $memc
.show( 'slow' );
122 // eslint-disable-next-line jquery/no-animate-toggle
123 $memc
.hide( 'slow' );
127 function areReqsSatisfied( name
) {
128 var i
, ext
, skin
, node
;
129 if ( !extDependencyMap
[ name
] ) {
133 if ( extDependencyMap
[ name
].extensions
) {
134 for ( i
in extDependencyMap
[ name
].extensions
) {
135 ext
= extDependencyMap
[ name
].extensions
[ i
];
136 node
= document
.getElementById( 'config_ext-' + ext
);
137 if ( !node
|| !node
.checked
) {
142 if ( extDependencyMap
[ name
].skins
) {
143 for ( i
in extDependencyMap
[ name
].skins
) {
144 skin
= extDependencyMap
[ name
].skins
[ i
];
145 node
= document
.getElementById( 'config_skin-' + skin
);
146 if ( !node
|| !node
.checked
) {
155 // Disable checkboxes if the extension has dependencies
156 $( '.mw-ext-with-dependencies input' ).prop( 'disabled', true );
157 $( '.config-ext-input[data-name]' ).on( 'change', function () {
158 $( '.mw-ext-with-dependencies input' ).each( function () {
159 var name
= this.getAttribute( 'data-name' );
160 if ( areReqsSatisfied( name
) ) {
162 this.disabled
= false;
164 // Uncheck and disable the checkbox
165 this.checked
= false;
166 this.disabled
= true;